<template>
  <div>
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="100px"
    >
      <el-form-item label="会员ID" prop="custom_id">
        <el-input v-model="form.custom_id" readonly placeholder="请输入会员ID" />
      </el-form-item>
      <el-form-item label="充值方式" prop="type">
        <el-radio-group v-model="form.type">
          <el-radio v-for="(item,index ) in typeList" :label="index" :key="item">{{item}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="金额" prop="coin">
        <el-input v-model="form.coin" maxlength="9" @input="(e) => (form.coin= integerZeroFn(e))"  placeholder="请输入金额" />
      </el-form-item>
      <el-form-item label="广告币数量" prop="score">
        <el-input v-model="form.score"
          @input="(e) => (form.score= integerZeroFn(e))"
          maxlength="9" placeholder="请输入广告币数量" />
      </el-form-item>
      <el-form-item label="订单ID" prop="order_id">
        <el-input v-model="form.order_id" maxlength="30" placeholder="请输入订单ID" />
      </el-form-item>
      <el-form-item label="备注" prop="msg">
        <el-input v-model="form.msg" type="textarea" rows="3" maxlength="200" show-word-limit placeholder="请输入备注" />
      </el-form-item>
    </el-form>
    <div class="flexend">
      <el-button @click="handleCloseAdd">取 消</el-button>
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </div>
  </div>
</template>

<script>
import { validPhone } from "@/utils/validate";
import { payOrder } from "@/api/advmaster";
export default {
  data() {
    return {
      form: {
        custom_id:'',
        type:'1',
        phone:"",
        email:"",
        status:'',
        password:'',
      },
      // 表单校验
      rules: {
        custom_id: [{ required: true, message: "会员id不能为空", trigger: "blur" }],
        type: [{ required: true, message: "请选择充值方式", trigger: "change" }],
        coin: [{ required: true, message: "请输入充值金额", trigger: "blur" }],
        score: [{ required: true, message: "请输入广告币数量", trigger: "blur" }],
        order_id: [{ required: true, message: "请输入订单号", trigger: "blur" }],
      },
      typeList:[],
    };
  },
  props: {
    rowitem: {
      default: null,
    },
  },
  created() {
    this.form.custom_id = this.rowitem.id;
    this.getDicts('/manager/api/getRechargePayType').then(res=>{
      this.typeList = res.data
    })
  },
  methods: {
    submitForm: function () {
      console.log('111"')
      this.$refs["form"].validate((valid) => {
        if (valid) {
          payOrder(this.form).then(() => {
            this.$modal.msgSuccess("修改成功");
            this.$emit("close", 1);
          });
        }
      });
    },

    handleCloseAdd() {
      this.$emit("close");
    },
  },
};
</script>